package edu.dayu.Builder;

public class Person {
    private Integer id; // 必选
    private String name; // 必选
    private String sex;  // 必选
    private Integer age; // 可选
    private String tel;  // 可选

    private Person(Builder builder){
        this.id = builder.id;
        this.name = builder.name;
        this.sex = builder.sex;
        this.age = builder.age;
        this.tel = builder.tel;
    }

    public static class Builder{
        private Integer id; // 必选
        private String name; // 必选
        private String sex;  // 必选
        private Integer age; // 可选
        private String tel;  // 可选

        public Builder(Integer id, String name ,String sex) {
            this.id = id;
            this.name = name;
            this.sex = sex;
        }

        public Builder setAge(Integer age){
            this.age = age;
            return this;
        }

        public Builder setTel(String tel){
            this.tel = tel;
            return this;
        }

        public Person build(){
            return  new Person(this);
        }

    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", tel='" + tel + '\'' +
                '}';
    }
}
